package adapter;


import java.util.List;

import com.example.qr_codescan.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import bean.Book;

public class BookAdapter extends BaseAdapter {
	
	private  List<Book> listbook;
	private Context mContext;

	public BookAdapter( Context mContext,List listbook){
		this.mContext=mContext;
		this.listbook=listbook;		
	}
	

	@Override
	public int getCount() {
		return listbook.size();
	}

	@Override
	public Object getItem(int position) {
		return listbook.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		View view = View.inflate(mContext, R.layout.borrowbook, null);
		Book book=listbook.get(position);
//		ImageView img=(ImageView)view.findViewById(R.id.borrowbookimg);
		TextView bookname=(TextView)view.findViewById(R.id.borrowbookname);
		TextView bookauther=(TextView)view.findViewById(R.id.borrowbookauther);
		TextView publish=(TextView)view.findViewById(R.id.borrowpublish);
		ImageView iv=(ImageView)view.findViewById(R.id.borrowbookimg);
		ImageLoader.getInstance().loadImage(book.getBookImage(),iv,true);
		bookname.setText(book.getBookName());
		bookauther.setText(book.getBookAuthor());
		publish.setText(book.getBookPublisherid());
		return view;
	}

}
